/**
 * @file		dd_pmc.h
 * @brief		PMC driver
 * @note		None
 * @attention	None
 * 
 * <B><I>Copyright 2016 Socionext Inc.</I></B>
 */

/** @weakgroup dd_pmc_overview
@{
	CM0 PMC Driver.<br>
@}*//* --- end of dd_pmc_overview */

#ifndef _DD_PMC_H_
#define _DD_PMC_H_

/** @weakgroup dd_pmc_definition
@{*/

#include "pmc.h"
#include "dd_arm.h"

/*----------------------------------------------------------------------*/
/* Definition															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Enumeration															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Structure															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Global Data															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Macro																*/
/*----------------------------------------------------------------------*/
// GPIO initial inputs code register
#define	Dd_PMC_GPIO_IICR_Get_P07_00()		(IO_PMC.GPIO_IICR.word & 0x000000FF)		/**< Get initial inputs code of GPIO(P07-P00) */
#define	Dd_PMC_GPIO_IICR_Get_P17_10()		((IO_PMC.GPIO_IICR.word & 0x0000FF00) >> 8)	/**< Get initial inputs code of GPIO(P17-P10) */

// Internal reset signal indication register
#define	Dd_PMC_GPIO_IRSIR_Get_HRRSTX()		(IO_PMC.IRSIR.word)							/**< Get internal reset signal indication */

// MDR
#define	Dd_PMC_MDR_Get_VER()				((IO_PMC.MDR.word & 0xF0000000) >> 28)		/**< Get chip version */
#define	Dd_PMC_MDR_Get_MD()					(IO_PMC.MDR.word & 0x0000003F)				/**< Get MD5-MD0 pin's value directry. */

// PERSELM1
#define	Dd_PMC_PERSELM1_Get_I2CHCNT()		(IO_PMC.PERSELM1.bit.I2CHCNT)											/**< Get selection whether noise filter of I2C(ISCLH) exists or not. */
#define	Dd_PMC_PERSELM1_Set_I2CHCNT(val)	{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.I2CHCNT=val;Dd_ARM_EI(s);}		/**< Set selection whether noise filter of I2C(ISCLH) exists or not. */
#define	Dd_PMC_PERSELM1_Get_SDANCH()		(IO_PMC.PERSELM1.bit.SDANCH)											/**< Get selection whether noise filter of I2C(ISDAH) exists or not. */
#define	Dd_PMC_PERSELM1_Set_SDANCH(val)		{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.SDANCH=val;Dd_ARM_EI(s);}		/**< Set selection whether noise filter of I2C(ISDAH) exists or not. */
#define	Dd_PMC_PERSELM1_Get_SCLNCH()		(IO_PMC.PERSELM1.bit.SCLNCH)											/**< Get the number of stages of the noise filter. */
#define	Dd_PMC_PERSELM1_Set_SCLNCH(val)		{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.SCLNCH=val;Dd_ARM_EI(s);}		/**< Set the number of stages of the noise filter. */

#define	Dd_PMC_PERSELM1_Get_SP0MISOPE()		(IO_PMC.PERSELM1.bit.SP0MISOPE)											/**< Get the Pull-Up/Down resistance of SP0MISO terminal On or Off. */
#define	Dd_PMC_PERSELM1_Set_SP0MISOPE(val)	{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.SP0MISOPE=val;;Dd_ARM_EI(s);}	/**< Set the Pull-Up/Down resistance of SP0MISO terminal On or Off. */
#define	Dd_PMC_PERSELM1_Get_SP0MOSIPE()		(IO_PMC.PERSELM1.bit.SP0MOSIPE)											/**< Get the Pull-Up/Down resistance of SP0MOSI terminal On or Off. */
#define	Dd_PMC_PERSELM1_Set_SP0MOSIPE(val)	{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.SP0MOSIPE=val;Dd_ARM_EI(s);}	/**< Set the Pull-Up/Down resistance of SP0MOSI terminal On or Off. */
#define	Dd_PMC_PERSELM1_Get_SP0SCKPE()		(IO_PMC.PERSELM1.bit.SP0SCKPE)											/**< Get the Pull-Up/Down resistance of SP0SCK terminal On or Off. */
#define	Dd_PMC_PERSELM1_Set_SP0SCKPE(val)	{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.SP0SCKPE=val;Dd_ARM_EI(s);}	/**< Set the Pull-Up/Down resistance of SP0SCK terminal On or Off. */
#define	Dd_PMC_PERSELM1_Get_SP0CSPE()		(IO_PMC.PERSELM1.bit.SP0CSPE)											/**< Get the Pull-Up/Down resistance of SP0CSX terminal On or Off. */
#define	Dd_PMC_PERSELM1_Set_SP0CSPE(val)	{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.SP0CSPE=val;Dd_ARM_EI(s);}		/**< Set the Pull-Up/Down resistance of SP0CSX terminal On or Off. */
#define	Dd_PMC_PERSELM1_Get_SP0MISOUDC()	(IO_PMC.PERSELM1.bit.SP0MISOUDC)										/**< Get the Pull-up/down resistance of SP0MISO terminal Pull-down or Pull-up. */
#define	Dd_PMC_PERSELM1_Set_SP0MISOUDC(val)	{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.SP0MISOUDC=val;Dd_ARM_EI(s);}	/**< Set the Pull-up/down resistance of SP0MISO terminal Pull-down or Pull-up. */
#define	Dd_PMC_PERSELM1_Get_SP0MOSIUDC()	(IO_PMC.PERSELM1.bit.SP0MOSIUDC)										/**< Get the Pull-up/down resistance of SP0MOSI terminal Pull-down or Pull-up. */
#define	Dd_PMC_PERSELM1_Set_SP0MOSIUDC(val)	{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.SP0MOSIUDC=val;Dd_ARM_EI(s);}	/**< Set the Pull-up/down resistance of SP0MOSI terminal Pull-down or Pull-up. */
#define	Dd_PMC_PERSELM1_Get_SP0SCKUDC()		(IO_PMC.PERSELM1.bit.SP0SCKUDC)											/**< Get the Pull up/down selection of SP0SCK terminal Pull-down or Pull-up. */
#define	Dd_PMC_PERSELM1_Set_SP0SCKUDC(val)	{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.SP0SCKUDC=val;Dd_ARM_EI(s);}	/**< Set the Pull up/down selection of SP0SCK terminal Pull-down or Pull-up. */
#define	Dd_PMC_PERSELM1_Get_SP0CSUDC()		(IO_PMC.PERSELM1.bit.SP0CSUDC)											/**< Get the Pull up/down selection of SP0CSX terminal Pull-down or Pull-up. */
#define	Dd_PMC_PERSELM1_Set_SP0CSUDC(val)	{INT32 s=Dd_ARM_DI();IO_PMC.PERSELM1.bit.SP0CSUDC=val;Dd_ARM_EI(s);}	/**< Set the Pull up/down selection of SP0CSX terminal Pull-down or Pull-up. */


// DBCNTM1
#define	Dd_PMC_DBCNTM1_Get_T00DCM()			(IO_PMC.DBCNTM1.bit.T00DCM)												/**< Get the control drivability 00. */
#define	Dd_PMC_DBCNTM1_Set_T00DCM(val)		{INT32 s=Dd_ARM_DI();IO_PMC.DBCNTM1.bit.T00DCM=val;Dd_ARM_EI(s);}		/**< Set the control drivability 00. */
#define	Dd_PMC_DBCNTM1_Get_T01DCM()			(IO_PMC.DBCNTM1.bit.T01DCM)												/**< Get the control drivability 01. */
#define	Dd_PMC_DBCNTM1_Set_T01DCM(val)		{INT32 s=Dd_ARM_DI();IO_PMC.DBCNTM1.bit.T01DCM=val;Dd_ARM_EI(s);}		/**< Set the control drivability 01. */
#define	Dd_PMC_DBCNTM1_Get_T02DCM()			(IO_PMC.DBCNTM1.bit.T02DCM)												/**< Get the control drivability 02. */
#define	Dd_PMC_DBCNTM1_Set_T02DCM(val)		{INT32 s=Dd_ARM_DI();IO_PMC.DBCNTM1.bit.T02DCM=val;Dd_ARM_EI(s);}		/**< Set the control drivability 02. */
#define	Dd_PMC_DBCNTM1_Get_T03DCM()			(IO_PMC.DBCNTM1.bit.T03DCM)												/**< Get the control drivability 03. */
#define	Dd_PMC_DBCNTM1_Set_T03DCM(val)		{INT32 s=Dd_ARM_DI();IO_PMC.DBCNTM1.bit.T03DCM=val;Dd_ARM_EI(s);}		/**< Set the control drivability 03. */
#define	Dd_PMC_DBCNTM1_Get_T04DCM()			(IO_PMC.DBCNTM1.bit.T04DCM)												/**< Get the control drivability 04. */
#define	Dd_PMC_DBCNTM1_Set_T04DCM(val)		{INT32 s=Dd_ARM_DI();IO_PMC.DBCNTM1.bit.T04DCM=val;Dd_ARM_EI(s);}		/**< Set the control drivability 04. */
#define	Dd_PMC_DBCNTM1_Get_T05DCM()			(IO_PMC.DBCNTM1.bit.T05DCM)												/**< Get the control drivability 05. */
#define	Dd_PMC_DBCNTM1_Set_T05DCM(val)		{INT32 s=Dd_ARM_DI();IO_PMC.DBCNTM1.bit.T05DCM=val;Dd_ARM_EI(s);}		/**< Set the control drivability 05. */
#define	Dd_PMC_DBCNTM1_Get_T06DCM()			(IO_PMC.DBCNTM1.bit.T06DCM)												/**< Get the control drivability 06. */
#define	Dd_PMC_DBCNTM1_Set_T06DCM(val)		{INT32 s=Dd_ARM_DI();IO_PMC.DBCNTM1.bit.T06DCM=val;Dd_ARM_EI(s);}		/**< Set the control drivability 06. */

// AVS
#define	Dd_PMC_AVS_Get_AVS()				(IO_PMC.AVS.word)							/**< Get AVS code. */

/*----------------------------------------------------------------------*/
/* Function																*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/* @} */	// dd_pmc_definition group

#endif	// _DD_PMC_H_
